<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 给一个数字数组，该数组中有很多数字0，将不为0的数据存入到一个新的数组中
        let arr = [0, 9, 0, 5, 0, 5, 50, 0, 7, 0]
        let arr2 = []

        for (let i = 0; i < arr.length; i++) {
            // console.log(arr[i]);
            if (arr[i] === 0) {
                // 为0的数组
                console.log(arr[i])
            } else {
                arr2.push(arr[i])

            }
        }
        // 不为0的数组
        console.log(arr2);
    </script>
</body>

</html>